package com.ouryue.test.imp;

import java.util.UUID;

import org.light.framework.bean.OperateResult;
import org.light.framework.service.BaseService;
import org.light.framework.util.DateHelper;
import org.light.framework.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ouryue.test.bean.User;
import com.ouryue.test.service.IUserService;


@Transactional
@Service
public class UserService extends BaseService<User> implements IUserService {

	@Transactional
	public OperateResult test(User obj) throws Exception {

		if (StringUtil.isNullOrEmpty(obj.getId()))
			obj.setId(UUID.randomUUID().toString());
		if (obj.getTimeCreated() == null)
			obj.setTimeCreated(DateHelper.getNowDate());

		OperateResult result= super.create(obj);
	
		result= super.create(obj);
		if(result.isSucced==false){
			throw new Exception(result.message);
		}		
		return result;
	}
}
